package distributedbank;
import distributedbank.client.ClientUI;
import distributedbank.server.BankBranch;
/**
 * Main Class 
 */
public class DistributedBank {	
    /**
     * Main function entry
     * @param args[0]: JVM number.
     * 1-4: bank branch
     * 5-8: clientUI
     */
    public static void main(String[] args) {
        if (args.length != 1) {
            throw new IllegalArgumentException("Bank components must be passed a "
                                             + "branch # argument to run");
        } else {
            int paramId;
            try {
                paramId = Integer.parseInt(args[0]);
            } catch (java.lang.NumberFormatException nfe) {
                System.out.println("Parameter Error!");
                return;
            }
            if (paramId < 5){
                BankBranch branch = new BankBranch(paramId);
                branch.runServer();
            } else {
                new ClientUI(paramId);
            }
        }
    }
}
